
*	************************************************************************
* 	File-Name: 		EGY_2014_Slums_replication.do
*	Date:  			1 January 2015
*	Authors: 		Michael Aklin, Patrick Bayer, S.P. Harish, and Johannes Urpelainen
*	Journal:		Energy
* 	Paper:			Quantifyling Slum Electrification in India and Explaining Local Variation
*
*	Data Used:  	SlumsIndia.dta	(through running Prep.do)
*	Purpose:   		.do file for replication
*	Software:		Stata IC 13.0
*	Machine:		WINDOWS 8.1
*
*	************************************************************************

clear all
set more off, permanently

* NB: Please place .do file and data in the same folder
* Data is loaded and cleaned by running the Prep.do file
do "Prep.do"

* Set survey weights
svyset _n [pweight = SWEIGHT]

*	************************************************************************
*	(I) MAIN TEXT
*	************************************************************************

*	************************************************************************
*	1. Summary statistics (Table 1)
*	************************************************************************

eststo clear
estpost tabstat FU1 FU1A factor1 FM3 HHED5ADULT NPERSONS [aweight = SWEIGHT] ///
		, 	///
		by(ID9)	///
		statistics(mean sd min max n)	/// 
		columns(statistics)

*	************************************************************************
*   2. Analysis (Table 2)
*		FU1: electricity (0,1)
*		FU1A: hours of electricity (0,24)
*	************************************************************************

eststo clear
eststo: logit FU1 rural urban [pweight = SWEIGHT], robust cluster(STATEID)
eststo: logit FU1 rural urban statefe* [pweight = SWEIGHT], robust cluster(STATEID)
eststo: logit FU1 rural urban factor1 statefe* [pweight = SWEIGHT], robust cluster(STATEID)
eststo: logit FU1 rural urban factor1 FM3 HHED5ADULT NPERSONS statefe* [pweight = SWEIGHT], robust cluster(STATEID)
eststo: reg FU1A rural urban [pweight = SWEIGHT], robust cluster(STATEID)
eststo: reg FU1A rural urban statefe* [pweight = SWEIGHT], robust cluster(STATEID)
eststo: reg FU1A rural urban factor1 statefe* [pweight = SWEIGHT], robust cluster(STATEID)
eststo: reg FU1A rural urban factor1 FM3 HHED5ADULT NPERSONS statefe* [pweight = SWEIGHT], robust cluster(STATEID)

		

*	************************************************************************
*	(II) APPENDIX
*	************************************************************************

*	************************************************************************
*   A2. Summary Statistics (Table A1)
*	************************************************************************

eststo clear
estpost tabstat FU1 FU1A elecasset1 rural urbanslum factor1 factoralt1 lognetincome FM3 HHED5ADULT NPERSONS ///
		, 	///
		by(ID9)	///
		statistics(mean sd min max n)	/// 
		columns(statistics)

*	************************************************************************
*   A3. Robustness Tests (Tables A2-A6) 
*	************************************************************************

* Controlling for income (Table A2)
eststo clear
eststo: logit FU1 rural urbanslum [pweight = SWEIGHT], robust cluster(STATEID)
eststo: logit FU1 rural urbanslum statefe* [pweight = SWEIGHT], robust cluster(STATEID)
eststo: logit FU1 rural urbanslum factor1 statefe* [pweight = SWEIGHT], robust cluster(STATEID)
eststo: logit FU1 rural urbanslum factor1 lognetincome FM3 HHED5ADULT NPERSONS statefe* [pweight = SWEIGHT], robust cluster(STATEID)
eststo: reg FU1A rural urbanslum [pweight = SWEIGHT], robust cluster(STATEID)
eststo: reg FU1A rural urbanslum statefe* [pweight = SWEIGHT], robust cluster(STATEID)
eststo: reg FU1A rural urbanslum factor1 statefe* [pweight = SWEIGHT], robust cluster(STATEID)
eststo: reg FU1A rural urbanslum factor1 lognetincome FM3 HHED5ADULT NPERSONS statefe* [pweight = SWEIGHT], robust cluster(STATEID)


* Ownership of electric assets as alternative DV (Table A3)
eststo clear
eststo: reg elecasset1 rural urbanslum [pweight = SWEIGHT], robust cluster(STATEID)
eststo: reg elecasset1 rural urbanslum statefe* [pweight = SWEIGHT], robust cluster(STATEID)
eststo: reg elecasset1 rural urbanslum factor1 statefe* [pweight = SWEIGHT], robust cluster(STATEID)
eststo: reg elecasset1 rural urbanslum factor1 FM3 HHED5ADULT NPERSONS statefe* [pweight = SWEIGHT], robust cluster(STATEID)

* Variation among slums (Table A4)
eststo: logit FU1 factor1 [pweight = SWEIGHT] if urbanslum == 1, robust cluster(STATEID)
eststo: logit FU1 factor1 statefe* [pweight = SWEIGHT] if urbanslum == 1, robust cluster(STATEID)
eststo: logit FU1 factor1 lognetincome FM3 HHED5ADULT NPERSONS statefe* [pweight = SWEIGHT] if urbanslum == 1, robust cluster(STATEID)
eststo: reg FU1A factor1 statefe* if urbanslum == 1, robust cluster(STATEID)
eststo: reg FU1A factor1 statefe* [pweight = SWEIGHT] if urbanslum == 1, robust cluster(STATEID)
eststo: reg FU1A factor1 lognetincome FM3 HHED5ADULT NPERSONS statefe* [pweight = SWEIGHT] if urbanslum == 1, robust cluster(STATEID)

* Alternative wealth measure (Table A5)
eststo clear
eststo: logit FU1 rural urbanslum [pweight = SWEIGHT], robust cluster(STATEID)
eststo: logit FU1 rural urbanslum statefe* [pweight = SWEIGHT], robust cluster(STATEID)
eststo: logit FU1 rural urbanslum factoralt1 statefe* [pweight = SWEIGHT], robust cluster(STATEID)
eststo: logit FU1 rural urbanslum factoralt1 FM3 HHED5ADULT NPERSONS statefe* [pweight = SWEIGHT], robust cluster(STATEID)
eststo: reg FU1A rural urbanslum [pweight = SWEIGHT], robust cluster(STATEID)
eststo: reg FU1A rural urbanslum statefe* [pweight = SWEIGHT], robust cluster(STATEID)
eststo: reg FU1A rural urbanslum factoralt1 statefe* [pweight = SWEIGHT], robust cluster(STATEID)
eststo: reg FU1A rural urbanslum factoralt1 FM3 HHED5ADULT NPERSONS statefe* [pweight = SWEIGHT], robust cluster(STATEID)

* New weighting scheme (Table A6)
gen sw2 = SWEIGHT
replace sw2 = sw2*3.5 if urbanslum == 1
tab ID9 [iweight = sw2]

eststo: logit FU1 rural urban [pweight = sw2], robust cluster(STATEID)
eststo: logit FU1 rural urban statefe* [pweight = sw2], robust cluster(STATEID)
eststo: logit FU1 rural urban factor1 statefe* [pweight = sw2], robust cluster(STATEID)
eststo: logit FU1 rural urban factor1 FM3 HHED5ADULT NPERSONS statefe* [pweight = sw2], robust cluster(STATEID)
eststo: reg FU1A rural urban [pweight = sw2], robust cluster(STATEID)
eststo: reg FU1A rural urban statefe* [pweight = sw2], robust cluster(STATEID)
eststo: reg FU1A rural urban factor1 statefe* [pweight = sw2], robust cluster(STATEID)
eststo: reg FU1A rural urban factor1 FM3 HHED5ADULT NPERSONS statefe* [pweight = sw2], robust cluster(STATEID)

